#include<iostream>
#include<string>
#define maxsize 100000
using namespace std;
int main (void)
{
	char s1[maxsize];
	char s2[maxsize];
	int i,k,j,max_count=0,max_num=0,count,num;
	gets(s1);
	gets(s2);
	for(i=0;s1[i];i++)
	{
		for(k=0;s2[k];k++)
		{
			count=0;
			if(s1[i]==s2[k]){
				j = i; 
				num=k;
				while( s1[j] && s2[k] && s1[j]==s2[k] ){
					count++;
					j++;
					k++;
				}
			}
			else
				continue;
			if(max_count<count){
				max_num = num;
				max_count = count;
			}
			k--;
		}
	}
	if(!max_count) 
		cout<<"NULL";
	else
		for(k=0;k<max_count;k++)
			cout<<s2[max_num+k];
	return 0;
 } 
